package com.fy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fy.pojo.entity.FileInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;


@Mapper
public interface FileInfoMapper extends BaseMapper<FileInfo> {
    /**
     * 更新回收站状态
     *
     * @param fileId
     * @param newDelFlag
     * @param now
     */
    @Update("UPDATE file_info SET del_type = #{newDelFlag}, recovery_time = #{now} WHERE file_id = #{fileId}")
    void updateDelFlagByFileId(String fileId,int newDelFlag, @Param("now") Date now);

    @Select("SELECT COUNT(*) FROM file_info WHERE del_type in (#{flag1},#{flag2}) AND object_name=#{objectName} and user_id=#{userId};")
    int countByCondition(int flag1,int flag2, String objectName,int userId);

}
